<?php
/*
 * @Author: your name
 * @Date: 2019-12-15 22:19:32
 * @LastEditTime: 2019-12-17 00:12:40
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \frame\app\ctrl\indexCtrl.php
 */

namespace app\ctrl;

use app\model\testModel;

class indexCtrl extends \core\imooc
{

    public function index()
    {
        $model = new testModel();
        $data = $model->lists();
        $this->assign('data',$data);
        $this->display('index.html');
    }
    
    public function add()
    {
        $this->display('add.html');
    }

    public function del()
    {
        $id = get('id');
        $testModel = new testModel();
        $testModel->delOne($id);
        jump('/index/index');
    }

    public function save()
    {
        $title = post('title');
        $content = post('content');
        $create_time = time();
        $testModel = new testModel();
        $testModel->addOne([
            'title' => $title,
            'content' => $content,
            'create_time' => $create_time,
        ]);
        jump('/index/index');
    }

}